package com.itheima.demo1;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Scanner;

public class ArrayTest2 {
    public static void main(String[] args) {
        //已知静态数组
        int[] arr = {19, 28, 37, 46, 50};
        //查找该数据在数组中的索引.差在控制台输出
        Scanner sc = new Scanner(System.in);
        //假设要查找的数据在数组中不存在
        int index = -1;
        System.out.println("输入数据:");
        while (true) {
            int num = sc.nextInt();
            for (int i = 0; i < arr.length; i++) {
                //如果输入的值是数据里的值,那么就把索引赋值给他
                if (arr[i] == num) {
                    //赋值给索引.并结束循环
                    index = i;
                    break;
                }
            }
            System.out.println(index);
        }
    }
}


